< previous page page_93 next page >

Page 93
added a toolbar or status bar to your form yet, lets disable the menu items under the View menu. Also, lets disable the Save button, because when a form is first loaded, theres nothing to save. Heres how:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub Form_Load()
   mnuVToolbar.Enabled = False
   mnuVStatus.Enabled = False
   cmdSave.Enabled = False
End Sub
Notice how you use the name of the control followed by a period and then the name of the property you want to change. This is the standard format for setting properties at runtime and for invoking methods on an object.
Form_Resize( )
The Form_Resize() event happens whenever a form is resized by the user at runtime or by your source code. For example, the following code causes the Resize event to fire:
9f31265bb40b592b1929e18a47ab28e5.gif
Me.Height = Me.Height + 100
The Me keyword always refers to the current form. By changing the Height property of the form, youre causing the form to resize itself. This fires the Resize() event. A common use of the Resize() event is to shrink or move the controls on the form. You can also use this event to prevent the form from growing too large or shrinking too small.
Form_Activate( )
The Form_Activate() event occurs after all the other form events have been fired. This event also occurs anytime you give a form focus. If you have several forms open and you move back and forth between each one, each form gets an Activate() event as you move to it.
Common uses of the Activate() event are to update a status bar with the current forms name and to enable buttons that were turned off during a Deactivate() event. Heres an example of the latter use:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub Form_Activate()
   cmdClose.Enabled = True
End Sub
Ill typically turn off the buttons on a form when it loses focus. This way, users cannot fire events on a form that they dont intend to fire them on.

 
< previous page page_93 next page >

If you like this book, buy it!